<template>
    <div id="adminversion">
        <div class="jx-content">
            <div class="display-item">
                <div class="item-title">系统版本内容</div>
                <div class="item-box">
                    <el-input
                        type="textarea"
                        v-model="textarea"
                        maxlength="5000"
                        show-word-limit
                    >
                    </el-input>
                </div>
            </div>
            <el-button class="button-style saveBtn" @click="save"  >保存</el-button>
        </div>
    </div>
</template>

<script>
    export default {
        data() {
            return {
                diplay1: '1',
                textarea: ''
            }
        },
        created() {
            let self = this
            self.initVersion()
        },
        methods: {
            initVersion(){
                let self = this
                self.$http.get('/tes/unauthorized/config?keys=version').then(response => {
                    let res = response.data
                    if(res.code === 200){
                        self.textarea = res.data.version[0].keyValue
                    }else{
                        self.$message.error(res.message)
                    }
                }).catch(err => {
                    console.log(err)
                })
            },
            // 保存
            save(){
                let self = this
                let data = []
                data = [
                    {

                        "keyValue": self.textarea,
                        "keyWord": "version"
                    }
                ]
                self.$http.put('/tes/unauthorized/config',data).then(response => {
                    let res = response.data
                    if(res.code === 200){
                        self.$message({
                            message: '保存成功',
                            type: 'success'
                        })
                    }else{
                        self.$message.error(res.message)
                    }
                }).catch(err => {
                    console.log(err)
                })
            }
        }
    }
</script>

<style lang="scss" scope>
    .jx-content{
        margin-top: 20px;
    }
    .display-item{
        margin-bottom: 70px;
        .item-title{
            font-size: 16px;
            color: #727272;
        }
        .item-box{
            margin-top: 15px;
        }
        .el-textarea{
            height: 180px;
        }
        .el-textarea__inner{
            resize: none;
        }
    }
    #adminversion{
        .button-style{
            width: 90px;
            margin: 50px auto;
            display: block;
        }
    }

</style>
